package com.example.demo.controller;

import com.example.demo.domain.result.CourseDataResult;
import com.example.demo.result.ApiResult;
import com.example.demo.service.CourseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author lizijian
 */
@RestController
@RequestMapping("/School/course")
@Slf4j
@Validated
@Api("课程接口")
public class CourseController {

  @Autowired
  private CourseService courseService;

  @ApiOperation(value = "模糊查询老师名字")
  @GetMapping("/teacherName/{teacherName}")
  public ApiResult<List<String>> getTeacherName(@NotNull @PathVariable String teacherName){
    return ApiResult.success(courseService.getTeacherName(teacherName));
  }

  @ApiOperation(value = "查询老师所教课程列表")
  @GetMapping("/courseOfTeacher/{teacherName}")
  public ApiResult<List<String>> getCoursesByTeacherName(@NotBlank @PathVariable String teacherName){
    return ApiResult.success(courseService.getCoursesByTeacherName(teacherName));
  }

  @ApiOperation(value = "获取指定老师，指定课程的信息")
  @GetMapping("/data")
  public ApiResult<List<CourseDataResult>> getCourseData(@NotNull String teacherName,@NotNull String courseName){
    return ApiResult.success(courseService.getCourseData(teacherName, courseName));
  }




}
